export default function({tapDay, today, funButtons, record, caseKey}){
  const $$ = wx.calendarInst.getDateHandle
  const that = this
  const key = caseKey;
  funButtons.dot.unshift({
    aim: 'onBukejian',
    itemClass: 'bukejian-case', 
    img: {src: '/images/bukejian.png'}
  })
  funButtons.dot = funButtons.dot.map(item=>{
    if (item.aim) {
      item.aim = item.aim + '?key='+key+'&type=memo'
    }
    return item
  })

  const title = `${today.year}/${today.month}/${today.day}(${today.lunarDate.ncWeek})记录`
  const content = {body: [title], date: tapDay.timestr, itemClass: 'memo', ...funButtons}

  let isHideMemo = false
  function beforeCallback({createCaseCard}){
    wx.modalx.showModal({
      content: {
        // title: ['创建备忘录', '📙', '记录些什么'],
        title: [' ', '📙', '记录些什么'],
        body: [
          {
            title: '隐私备忘: ', 
            "@switch": { checked: false, itemStyle: 'margin-left: 1em', bindchange: 'onIsHideMemo'}, 
            itemStyle: 'display: flex; align-items: center; height: 2.7em;',
          },
          `当前日期：${tapDay.timestr}${tapDay.timestr === today.timestr ? '(今天)':''}`, 
          `点击<<确定>>将创建备忘录，隐私备忘可通过长按选定日期显示(默认隐藏)`, 
          {
            title: '我的备忘录', 
            itemClass: 'pop-case-scroll-bottom', 
            aim(){
              wx.modalx.closeModal()
              that.restoreCaseButton()
              wx.pageScrollTo({
                selector: '#pits-list-container',
                duration: 300,
                success(){
                  that.listCaseType('memo')
                }
              })
            }}, 
        ],
        onIsHideMemo(e){
          isHideMemo = e.detail.value
        },
        itemClass: 'inner-content',
      },
      confirmText: '确定',
      cancelText: '取消', 
      height: 60,
      width: 80,
      itemClass: 'popup memo', 
      mask: false,
      success(res){
        if (res.confirm) {
          if (isHideMemo) {
            content.hideDate = `${tapDay.month}-${tapDay.day}`
          }
          content.body[1] = '还什么都没记录'

          const timestr = tapDay.timestr
          const currentDay = $$(timestr)
          !content.hideDate && (currentDay && currentDay.addClass('memo'));
          createCaseCard(content)
        }
        that.restoreCaseButton()
      }
    })
  }
  return {key, content, beforeCallback}
}